package com.honglang.struts2.action;


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

import com.honglang.common.tools.ZipUtil;

public class DownloadFileAction extends BaseAction{
	
	
	
	
	public String downloadWithZip(){
		/**
		ZipUtil zipUtil = new ZipUtil();
		org.apache.tools.zip.ZipOutputStream zos = zipUtil.createZip("E:/test1.zip");
		List<String> fileList = new ArrayList<String>();
		fileList.add("E:/资料/freemarker中文手册.doc");
		fileList.add("E:/资料/ActionMapper.java");
		fileList.add("E:/aaa.txt");
		zipUtil.compress(fileList, zos);
		
		try {
			this.getResponse().addHeader("Content-Disposition", "attachment; filename=\"" + new String("test.zip".getBytes(), "iso-8859-1") + "\"");
			this.getResponse().setContentType("bin");
			InputStream in = new FileInputStream("E:/test1.zip");
			byte[] data = new byte[1024];
			int len;
			while((len = in.read(data)) >0){
				this.getResponse().getOutputStream().write(data,0,len);
				
			}
			in.close();
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("End");
		**/
		return null;
		
	}

}
